﻿using System;
using ExFlash.Records;

namespace ExFlash.Tags
{
    public class DefineShape4Tag : DefineShape3Tag
    {
        public RectangleRecord EdgeBounds
        {
            get;
            protected set;
        }

        public Boolean UsesFillWindingRule
        {
            get;
            protected set;
        }

        public Boolean UsesNonScalingStrokes
        {
            get;
            protected set;
        }

        public Boolean UsesScalingStrokes
        {
            get;
            protected set;
        }
        
        public override ShapeType TagType
        {
            get
            {
                return ShapeType.Shape4;
            }
        }

        protected DefineShape4Tag(TagCodes code, int len, int offset)
            : base(code,len,offset)
        {

        }

        public DefineShape4Tag(int len, int offset)
            : this(TagCodes.DefineShape4, len, offset)
        {

        }

        public override void SwfDeserialize(BinaryBitReader reader)
        {
            ShapeId = reader.ReadUInt16();

            ShapeBounds = new RectangleRecord();
            ShapeBounds.SwfDeserialize(reader);

            EdgeBounds = new RectangleRecord();
            EdgeBounds.SwfDeserialize(reader);

            reader.SkipBits(5);
            UsesFillWindingRule = reader.ReadBoolean();
            UsesNonScalingStrokes = reader.ReadBoolean();
            UsesScalingStrokes = reader.ReadBoolean();
            reader.AlignBits();

            Shapes = new ShapeWithStyle(TagType);
            Shapes.SwfDeserialize(reader);
        }
    }
}
